/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Examples;

import homomorphism.list.BasicListHomomorphismInterface;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.hadoop.io.FloatWritable;
import utility.Tuple;

/**
 *
 * @author takeshi
 * old , to be deleted
 */
public class Variance2 implements BasicListHomomorphismInterface<FloatWritable, Tuple<Float, Float, Integer>> {

    public Tuple filter(FloatWritable val) {
        final float v = val.get();
        Tuple<Float, Float, Integer> interTuple = new Tuple<Float, Float, Integer>();
        interTuple.Set1st(v * v);
        interTuple.Set2nd(v);
        interTuple.Set3rd(1);
        return interTuple;
    }

    public Tuple plus(Tuple<Float, Float, Integer> a, Tuple<Float, Float, Integer> b) {
        try {
            return Tuple.Sum(a, b);
        } catch (NullPointerException ex) {
            Logger.getLogger(Variance2.class.getName()).log(Level.SEVERE, null, ex);
        }
         return null;
    }

    public static void main(String[] args) throws IOException {// just for test
        Tuple<Float, Float, Integer> a = new Tuple<Float, Float, Integer>(1f, 1f, 1);
        Tuple<Float, Float, Integer> b = new Tuple<Float, Float, Integer>(1f, 1f, 1);
        Tuple<Float, Float, Integer> c = Tuple.Sum(a, b);
        System.out.println( c);
    }
    
}
